/*
 ***********************************
 * Classname: problem2_Garg
 * Version: 1.0
 * Date: 03/13/2009
 * Auhtor: Dilip Garg
 ***********************************
 */

 import java.util.Scanner; 

 /**
  * This class checks a given string is well parenthesised by using
  * a stack (implemented using Java Strings). The running time of the
  * algorithm is in O(n) i.e. linear time.
  */ 

public class problem2_Garg
{
	String str;
		
	// Default Constructor	
	public problem2_Garg()
	{
		str = "";
	}	
	
	// Main method
	public static void main(String[] args)
	{
		// Taking the string from the standard input
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		
		/*
		 *  If the given string is empty, return "YES"
		 */
		if (str.length() == 0) 
			System.out.println("YES");	
		/*
		 * Otherwise check for well parenthesized and print 
		 * the output on standard out.
		 */
		else 
			System.out.println(checkParenthesised(str));	
			
	}
	
	/**
	 * This method utilizes the Java String as a form of stack, it starts with
	 * pushing the first character of the string in to the stack, and checks
	 * that the next character in the input string matches with the top character
     * in the stack, if it does - then the top character is popped out of the 
	 * stack. if it does not match, then the unmatched character is inserted on 
	 * the top of the stack, and the algorithm continues.
	 * @arg input String
	 * @return "YES" if the string is well parenthesised, "NO" otherwise
	 */	
	public static String checkParenthesised(String input)
	{
		// Make a copy of the string
		String test = input;
		int strLen = test.length();
		
		// Push the first character of the string, into a stack
		String stack = Character.toString(test.charAt(0));
		
		// Iterate over all of the characters of the string, except the first	
		for (int j = 1; j+1 <= strLen; j++)
		{
			/* 
			 * If the stack is not empty, take out the top character of the 
			 * stack, and match it with the current character in the given string
			 */
			if ((stack.length() > 0) && (match(stack.charAt(stack.length() -1), test.charAt(j))))
			{
				/* 
				 * If there is a match, then pop the top character from the stack
				 */
				stack = stack.substring(0, stack.length() -1);
			}
			else
				/* 
				 * If either the stack is empty
				 *    or there is no match, then push the current character from the
        		 *       given string into the top of the stack
				 */
				stack = stack.concat(Character.toString(input.charAt(j)));
		}
		
		/*
		 * Once complete string gets traversed, check if the stack contains any items 
		 */
		if (stack.length() == 0) 
			return "YES"; // If empty, then the given string is well parenthesised, return "YES"
		else
			return "NO"; // Return "NO" otherwise
	}
	
	/**
	 * Given two characters, the method returns true if the characters are
	 * same, false otherwise.
	 * @arg1 first character
	 * @arg2 second character
	 * @return true/false
	 */
	public static boolean match(char a, char b)
	{
		if (((a == '(') & (b == ')')) | ((a == '{') & (b == '}')))
			return true;
		else 
			return false;
	}
}